<?php

include('include/functions.php');

$mysql = mysql_connect("localhost", "root", "kGbN85Z");
mysql_query("USE ftp;");

$res = mysql_query('SELECT kp_id FROM films;');
$count = mysql_num_rows($res);
$per_cent = 100/$count;
$i = 0;

while($row = mysql_fetch_row($res))
{
  $kp = new KinoPoisk($row[0]);
  $kp->GetPage();

  $query = "UPDATE `films` SET `films`.`desc`='".mysql_real_escape_string($kp->Desc())."' WHERE kp_id = $row[0];";
  mysql_query($query);
  $i += $per_cent;
  echo $i."%\n";
}
mysql_close($mysql);

?>
